﻿using System.Linq;
using Turquoise.Helpers;
using Turquoise.Services.Messaging.Entities;

namespace Turquoise.Services.Messaging.Helpers
{
    public static class EmailHelper
    {
        public static string ConvertTemplateToString(string emailTemplate, EmailRow emailRow)
        {
            return emailRow.EmailKeys.Aggregate(emailTemplate, (current, key) => StringHelper.TemplateParser(current, EmailConstants.EmailKeyRegEx.Replace(EmailConstants.EmailTokenName, key.Key.ToString()), key.Value));
        }
    }
}
